package com.offcn.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: wy
 * @Date: 2022/9/23 18:13
 */
@RestController
public class SendController05 {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 主题模式（Topic）
     *
     * @return
     */
    @RequestMapping("/send6")
    public String send4() {
        for (int i = 0; i < 3; i++) {
            String message = "主题模式（Topic）式者模式" + i;
            rabbitTemplate.convertAndSend("topicExchange", "topic.KeyA", message);
        }
        return "发送成功";
    }

    @RequestMapping("/send7")
    public String send5() {
        for (int i = 0; i < 5; i++) {
            String message = "主题模式（Topic）模式" + i;
            rabbitTemplate.convertAndSend("topicExchange", "topic.KeyB.KeyC", message);
        }
        return "发送成功";
    }

}
